
function goBackToMainScreen(event) {
	// Resets the list appearence after the user exits the event description
	$(".mapcontainer").css({ "display": "block" });
	
	// Bring back main screen toolbars
	$('.viewtogglebar_container').css({ "display": "block"});
	$('.sortingBar_container').css({ "display": "block"});
	$('.eventRangeBar_object').css({ "display": "block"});


	// Hide event description toolbars
	$('.eventDescription_toolbars').css({ "display": "none"});

	// Hide the liking buttons
	$('.eventDescription_preferenceObjects').css({ "display": "none"});
	$('.preferenceButtonWrapper').css({ "display": "none"});

	// bring back the most recent map view; 1 = splitscreen, 2 = map, 3 = list
	if (currentView == 1) {
		showSplitScreen();
	}
	if (currentView == 2) {
		showMapOnly();
	}
	if (currentView == 3) {
		showListOnly();
	}
	
	// Set the scroller to the proper height
	$('#expandedDescription').css({ "display": "none"});
	$('#wrapper').css({ "display": "block"});

	$('.preferenceButton').css({"opacity": "1"});
	$('#preference_likeButton').css({"background-image": "url('thumbsup.png')"});
	$('#preference_dislikeButton').css({"background-image": "url('thumbsdown.png')"});
	feedbackGiven = 0;
	$('#preferenceToolbar').css({ "display": "none"});
	$('.eventListToolbar').css({ "height": "38"});
	
}




function showEventDescription(index, eventName) {
	clickedEventIndex = index;
	$(".mapcontainer").css({ "display": "none" });
	$(".eventlist").css({ "width": "100%", "height": "100%", "visibility": "visible" });	

	// Hide the top two toolbars
	$('.viewtogglebar_container').css({ "display": "none"});
	$('.sortingBar_container').css({ "display": "none"});

	// Hide the lower navbar button
	$('.eventRangeBar_object').css({ "display": "none"});

	// Reveal the new toolbars
	$('.eventDescription_nametoolbar').css({ "display": "block"});
	var eventName = markerData[index][2];
	document.getElementById("eventnamelabel").innerHTML = eventName;

	$('.eventDescription_toolbars').css({ "display": "block"});
	$('.eventListToolbar').css({ "display": "block"});

	// Show the liking buttons
	$('.eventDescription_preferenceObjects').css({ "display": "block"});
	$('.preferenceButtonWrapper').css({ "display": "block"});
	

	$('#expandedDescription').css({ "display": "block"});
	$('#wrapper').css({ "display": "none"});


	var currentEventText = ( "("+String.fromCharCode("A".charCodeAt(0) + (markerData[index][9] + 1 - currentEventRangeIndex)) + ") " + markerData[index][2] 
					+ "<br><br>" + printTime(markerData[index][5]) + " - " + printTime(markerData[index][6]) + " at " + markerData[index][7] 
					+ "<br><br>Event Category: " + markerData[index][3] 
					+ "<br>Host: " + markerData[index][4]
					+ "<br><br>Description: " + markerData[index][8] );

	document.getElementById("expandedDescription").innerHTML = currentEventText;

		$('#preferenceToolbar').css({ "display": "block"});
}




function goToDirectionsScreen(event) { 
	var startLat = currentLat;
	var startLon = currentLon;
	var endLat = selectedEventLat;
	var endLon = selectedEventLon;
	var directionsUrl = "http://maps.google.com/maps?f=d&source=s_d&saddr=" + startLat + ",+" + startLon
			+ "&daddr=" + endLat + ",+" + endLon + "&dirflg=w";
	window.open(directionsUrl, 'toolbar=yes');
}



var clickedEventIndex;
var feedbackGiven = 0;


function acceptPositiveFeedback(event) {
	if (feedbackGiven == 0) {
	feedbackGiven = 1;
	$('#preference_dislikeButton').css({"opacity": ".3"});
	$('#preference_likeButton').css({"background-image": "url('thumbsup_clicked.png')"});

	host = markerData[clickedEventIndex][4];
	var x = -1;
	for (var i=0;i<preferences.length;i++){
		if(preferences[i][0] == host) {
		x = i;
		} 
	}
	
	if(x > -1) {
		preferences[x][1] = preferences[x][1] + 1;
	}
	}

}

function acceptNegativeFeedback(event) {
	if (feedbackGiven == 0) {
	feedbackGiven = 1;
	$('#preference_likeButton').css({"opacity": ".3"});
	$('#preference_dislikeButton').css({"background-image": "url('thumbsdown_clicked.png')"});

	host = markerData[clickedEventIndex][4];
	var x = -1;
	for (var i=0;i<preferences.length;i++){
		if(preferences[i][0] == host) {
		x = i;
		} 
	}

	if(x > -1) {
		preferences[x][1] = preferences[x][1] - 1;
	}
	}
}

var helpIsShowing = false;
function showPreferenceHelp(event) {
	if (helpIsShowing == false) {
		$('.eventListToolbar').css({ "height": "110"});
		helpIsShowing = true;
	} else {
		
		helpIsShowing = false;
		$('.eventListToolbar').css({ "height": "38"});
	}
}